// source --> http://www.kamiyuonsen.com/wp-content/plugins/biz-calendar/calendar.js?ver=2.2.0 jQuery(document).ready(function ($) { if ($("#biz_calendar").size() == 0) { return; } bizCalendar.start(); }); var bizCalendar = { start: function () { var now = new Date(); this.setting = { year: now.getFullYear(), month: now.getMonth() + 1, options: window.bizcalOptions }; document.getElementById('biz_calendar').innerHTML = this.getCalendar(); }, downMonth: function () { if (this.setting.month <= 1) { this.setting.month = 12; this.setting.year = this.setting.year - 1; } else { this.setting.month = this.setting.month - 1; } document.getElementById('biz_calendar').innerHTML = this.getCalendar(); }, upMonth: function () { if (this.setting.month >= 12) { this.setting.month = 1; this.setting.year = this.setting.year + 1; } else { this.setting.month = this.setting.month + 1; } document.getElementById('biz_calendar').innerHTML = this.getCalendar(); }, goToday: function () { var now = new Date(); if (this.setting.month == now.getMonth() + 1 && this.setting.year == now.getFullYear()) { return; } this.setting.year = now.getFullYear(); this.setting.month = now.getMonth() + 1; document.getElementById('biz_calendar').innerHTML = this.getCalendar(); }, getCalendar: function () { var weekArray = new Array("日", "月", "火", "水", "木", "金", "土"); var start_day = this.getStartDayOfMonth(this.setting.year, this.setting.month); var last_date = this.getEndDateOfMonth(this.setting.year, this.setting.month); var calLine = Math.ceil((start_day + last_date) / 7); var calArray = new Array(7 * calLine); // カレンダーの日付テーブル作成 for (var i = 0; i < 7 * calLine; i++) { if (i >= last_date) { break; } calArray[i + start_day] = i + 1; } // カレンダーのタイトル var title = this.setting.year + "年 " + this.setting.month + "月"; var html = "
" + title + " | "; html += this.getPrevMonthTag(); html += "![]() | ";
html += this.getNextMonthTag();
html += "|||
"; html += weekArray[i]; html += " | "; } html += "||||
---|---|---|---|---|
"; html += this.getDateTag(date, j); html += " | "; } html += "
" + this.setting.options.holiday_title + "
"; } return ""; }, getEventdayTitle: function () { if (this.setting.options.eventday_title == "") { return ""; } var tag = "" if (this.setting.options.eventday_url == "") { tag += this.setting.options.eventday_title + "
"; return tag; } tag += "" + this.setting.options.eventday_title + ""; return tag; }, getDateClass: function (date, day) { if (date == undefined || date == "") { return ""; } var today = this.isToday(date); var attr = ""; switch (this.getDateType(date, day)) { case "EVENTDAY": attr = today == false ? " class='eventday' " : " class='eventday today' "; return attr; case "HOLIDAY": attr = today == false ? " class='holiday' " : " class='holiday today' "; return attr; default: attr = today == false ? "" : " class='today' "; return attr; } return ""; }, isToday: function (date) { var now = new Date(); if (now.getFullYear() == this.setting.year && now.getMonth() + 1 == this.setting.month && now.getDate() == date) { return true; } return false; }, getDateTag: function (date, day) { if (date == undefined || date == "") { return ""; } var url = this.setting.options.eventday_url; if (url == "") { return date; } if (this.getDateType(date, day) == "EVENTDAY") { return tag = "" + date + ""; } return date; }, getDateType: function (date, day) { var fulldate = this.toFormatDate(this.setting.year, this.setting.month, date); // イベント日 if (this.setting.options.eventdays.indexOf(fulldate) != -1) { return "EVENTDAY"; } // 臨時営業日 if (this.setting.options.temp_weekdays.indexOf(fulldate) != -1) { return "WEEKDAY"; } // 臨時休業日 if (this.setting.options.temp_holidays.indexOf(fulldate) != -1) { return "HOLIDAY"; } // 定休日 var dayName = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]; if (this.setting.options[dayName[day]] == "on") { return "HOLIDAY"; } // 祝日 if (this.isHoliday(fulldate)) { return "HOLIDAY"; } return "WEEKDAY"; }, isHoliday: function (fulldate) { if (this.setting.options["holiday"] == undefined || this.setting.options["holiday"] == "off") { return false; } var holidays = this.setting.options["national_holiday"]; if (holidays == undefined) { return false; } for (var i = 0; i < holidays.length; i++) { if (holidays[i] == fulldate) { return true; } } return false; }, toFormatDate: function (y, m, d) { m = m < 10 ? "0" + m : m; d = d < 10 ? "0" + d : d; return y + "-" + m + "-" + d; }, getEndDateOfMonth: function (year, month) { var date = new Date(year, month, 0); return date.getDate(); }, getStartDayOfMonth: function (year, month) { var date = new Date(year, month - 1, 1); return date.getDay(); }, getPrevMonthTag: function () { var limit = this.setting.options["month_limit"]; var tag = "